<template>
	<view>
		<view class="btn">
			<button type="warn" class="button popup-error" @click="dialogToggle('error')">
				<text class="button-text error-text">退出登录</text>
			</button>
		</view>
		
		<!-- 提示窗示例 -->
		<uni-popup ref="alertDialog" type="dialog">
			<uni-popup-dialog :type="msgType" cancelText="取消" confirmText="同意" title="退出登录" content="您真的要退出登录吗?"
				@confirm="dialogConfirm" @close="dialogClose"></uni-popup-dialog>
		</uni-popup>
	</view>
</template>

<script>
	import {
		mapState,mapMutations
	}from 'vuex'
	export default {
		data() {
			return {
				
			};
		},
		methods: {
			...mapMutations('m_user',['updateUserInfo']),
			dialogToggle(type) {
				this.msgType = type
				this.$refs.alertDialog.open()
			},
			dialogConfirm() {
				console.log('点击确认')
				this.updateUserInfo('{}')
				this.$refs.alertDialog.close()
				uni.navigateTo({
					url: '../../pages/login/login'
				});
			},
			dialogClose() {
				console.log('点击关闭')
			},
		}
	}
</script>

<style lang="scss">
.btn{
	width: 100%;
	margin: 20px 0;
	text-align: center;
	button{
		width: 90%;
	}
}
</style>
